/**
 * Created by 75147 on 2017/6/8.
 */
app.controller("demoFormController",function($scope){
  $scope.isShow=false;
  $scope.title='添加信息';
  var Add_Mode;
  $scope.$on("to-demoFormController-add",function(){
    $scope.isShow=true;
    $scope.title='添加信息';
    Add_Mode=true;
  })
  $scope.close=function(isShow){
    $scope.isShow=isShow;
  }
  $scope.submit=function(){
    if(Add_Mode){
      $scope.$emit("to-demoListController-addData-success",$scope.formData);
    }else{
      $scope.$emit("to-demoListController-editData-success",$scope.formData);

    }
    $scope.close(false);
  }
  $scope.formData;

  $scope.$on("to-demoFormController-edit",function(event,data){
    $scope.isShow=true;
    $scope.title='编辑信息';
    $scope.formData=data.data;
    $scope.formData.index=data.index;
    Add_Mode=false;
    console.log($scope.formData);
  })
})